import sys

def update_result(current_k, current_a, current_b, max_k_val, res_a_val, res_b_val):
    """
    辅助函数，用于根据当前候选对 (current_k, current_a, current_b) 更新全局最优解。
    如果当前步数 current_k 更大，则直接更新。
    如果步数 current_k 相同，则根据 (a, b) 的字典序大小（先比较 a，后比较 b）更新。
    """
    if current_k > max_k_val:
        max_k_val = current_k
        res_a_val = current_a
        res_b_val = current_b
    elif current_k == max_k_val:
        # 如果步数相同，选择 (a, b) 字典序更大的组合
        if current_a > res_a_val:
            res_a_val = current_a
            res_b_val = current_b
        elif current_a == res_a_val and current_b > res_b_val:
            res_b_val = current_b
    return max_k_val, res_a_val, res_b_val

def solve():
    """解决单组测试数据的函数"""
    try:
        # 读取输入 A 和 B
        A, B = map(int, sys.stdin.readline().split())
    except (EOFError, ValueError):
        return

    # 初始值: (1,1) 是 (F_1, F_2)，对应 k=1，步数为 k+1=2。
    # 题目中 f(1,1)=2 的描述与此对应。
    max_k = 2
    res_a = 1
    res_b = 1

    # 初始化斐波那契数列的迭代器。
    # f_i 对应 F_k，f_i_plus_1 对应 F_{k+1}
    # 从 F_1, F_2 开始迭代，即 current_fib_idx = 1
    f_i = 1  # 对应 F_1
    f_i_plus_1 = 1  # 对应 F_2
    current_fib_idx = 1 # 当前 f_i 对应的斐波那契数列索引 k

    # 循环生成斐波那契数对并检查
    while True:
        # 候选对1: (F_k, F_{k+1})，即 (f_i, f_i_plus_1)
        # 对应的步数为 current_fib_idx + 1
        current_steps_1 = current_fib_idx + 1
        current_a_1 = f_i
        current_b_1 = f_i_plus_1

        valid1 = (current_a_1 <= A and current_b_1 <= B)

        if valid1:
            max_k, res_a, res_b = update_result(current_steps_1, current_a_1, current_b_1, max_k, res_a, res_b)

        # 候选对2: (F_{k+1}, F_k)，即 (f_i_plus_1, f_i)
        # 对应的步数为 current_fib_idx
        current_steps_2 = current_fib_idx
        current_a_2 = f_i_plus_1
        current_b_2 = f_i

        valid2 = (current_a_2 <= A and current_b_2 <= B)

        if valid2:
            max_k, res_a, res_b = update_result(current_steps_2, current_a_2, current_b_2, max_k, res_a, res_b)

        # 终止条件：如果当前生成的两个候选对都不在 [1,A]x[1,B] 的范围内，
        # 那么后续生成的更大斐波那契数对也肯定不会满足条件，可以提前终止循环。
        if not valid1 and not valid2:
            break

        # 生成下一个斐波那契数对的项
        next_f = f_i + f_i_plus_1
        f_i = f_i_plus_1
        f_i_plus_1 = next_f
        current_fib_idx += 1

    print(max_k, res_a, res_b)

def main():
    """主函数处理多组输入"""
    try:
        _str = sys.stdin.readline()
        if not _str: # 处理空输入，例如文件末尾或空行
            return
        T = int(_str)
        for _ in range(T):
            solve()
    except (EOFError, ValueError): # 捕获可能的输入错误或文件结束
        return

if __name__ == "__main__":
    main()
